package cate.game.pvp.ladder.msg;

import cate.game.GameBody;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInputTemplate;
import cate.game.client.msg.id.MsgIdBLadder;
import cate.game.role.Role;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "天梯 挑战 请求")
public class LadderChallengeReq extends MsgInputTemplate {

    @NoteField("挑战对手的ID")
    public String opponentId;

    @Override
    public MsgConfig conf() {
        return MsgIdBLadder.CHALLENGE_REQ;
    }

    @Override
    public void action(GameBody game, Role role) throws Exception {
        role.getPvp().ladder.challengeCheck(); // 如果不符合挑战条件，会抛出异常
        role.getPvp().ladder.challengeDo(game, this.opponentId); // 执行挑战
    }
}
